#pragma once

#include <vector>
#include <map>
#include <ctime>

#include "BankData.h"

#include "ParticipantExecutor.h"

namespace PC2
{

class PC2DataStore;


class TimeIDGenerator
{
public:
	TimeIDGenerator();


public:
	std::string GetNextID();


protected:
	time_t m_LastTime;
	uint32_t m_Count;


};


class BankTransactionStoreExecutor
	: public ParticipantExecutor
{
public:
	BankTransactionStoreExecutor(PC2DataStore* apStore);
	virtual ~BankTransactionStoreExecutor();

public:
	void DumpAllTransaction(std::vector<std::pair<std::string, BankTransaction> >* apVec);

public:
	bool Prepare( uint32_t aTransId, char const* apData, uint32_t aSize, leveldb::WriteBatch* apBatch );
	void Commit( uint32_t aTransId, char const* apData, uint32_t aSize, leveldb::WriteBatch* apBatch );
	void Abort( uint32_t aTransId, char const* apData, uint32_t aSize, leveldb::WriteBatch* apBatch );


protected:
	std::string GetNextID();

protected:
	PC2DataStore* m_pStore;
	TimeIDGenerator m_IDGenerator;
};



}